package com.example.elastic.document;

import lombok.Builder;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.data.elasticsearch.core.join.JoinField;

/**
 * @author zxs
 * @since 2022/5/9
 */
@Builder
@Data
@Document(indexName = "menu")
public class Menu {

    @Id
    private Integer id;

    @MultiField(mainField = @Field(type = FieldType.Text),otherFields = {@InnerField(suffix = "keyword",type = FieldType.Keyword)})
    private String path;

    @JoinTypeRelations(
            relations = {
                    @JoinTypeRelation(parent = "parent",children = {"children"})
            }
    )
    private JoinField<Integer> relation;
}
